﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using com.kmer;
using com.kmer.Attributes;
using com.kmer.interfaces;

namespace com.kmer.library.Factorys {
    /// <summary>
    /// 后台用户管理
    /// </summary>
    public class AdminUserFactory {
        private static IAdminUserFactory _cache;
        private static Type _factoryType;

        /// <summary>
        /// 实例
        /// </summary>
        public static IAdminUserFactory Instance => _cache ?? (_cache = BaseFactory<IAdminUserFactory, TestAdminUserFactory>.GetService(FactoryType));

        /// <summary>
        /// 实现此工程的实例类型
        /// </summary>
        public static Type FactoryType {
            get { return _factoryType; }
            set {
                if (_factoryType != value)
                    _cache = null;
                _factoryType = value;

            }
        }
    }
	/// <summary>
	/// 后台用户管理
	/// </summary>
	public class TestAdminUserFactory : IAdminUserFactory {
		/// <summary>
		/// 用户登录
		/// </summary>
		/// <param name="User"></param>
		/// <param name="Pass"></param>
		/// <returns></returns>
		public AdminLoginUserData Login(string User, string Pass)
		{
			throw new NotImplementedException();
		}
		/// <summary>
		/// 检查用户Token，有效则执行登陆
		/// </summary>
		/// <param name="Token"></param>
		public void CheckUserAccessToken(string Token)
		{
			throw new NotImplementedException();
		}
		/// <summary>
		/// 获取用户的角色
		/// </summary>
		/// <param name="staffNo"></param>
		/// <returns></returns>
		public IList<string> GetRoleForUser(string staffNo)
		{
			throw new NotImplementedException();
		}
		/// <summary>
		/// 判断用户是否系统管理员
		/// </summary>
		/// <param name="staffNo"></param>
		/// <returns></returns>
		public bool IsSystemAdmin(string staffNo)
		{
			throw new NotImplementedException();
		}

		/// <summary>
		/// 检查用户是否有效
		/// </summary>
		/// <param name="staffNo"></param>
		/// <returns></returns>
		public bool CheckUser(string staffNo)
		{
			throw new NotImplementedException();
		}
	}
}
namespace com.kmer.library {
	/// <summary>
	/// 后台用户管理
	/// </summary>
	public interface IAdminUserFactory:IFactory
    {
		/// <summary>
		/// 用户登录
		/// </summary>
		/// <param name="User"></param>
		/// <param name="Pass"></param>
		/// <returns></returns>
	    AdminLoginUserData Login(string User, string Pass);
		/// <summary>
		/// 检查用户Token，有效则执行登陆
		/// </summary>
		/// <param name="Token"></param>
	    void CheckUserAccessToken(string Token);
		/// <summary>
		/// 获取用户的角色
		/// </summary>
		/// <param name="staffNo"></param>
		/// <returns></returns>
		IList<string> GetRoleForUser(string staffNo);
		/// <summary>
		/// 判断用户是否系统管理员
		/// </summary>
		/// <param name="staffNo"></param>
		/// <returns></returns>
		bool IsSystemAdmin(string staffNo);
		/// <summary>
		/// 检查用户是否有效
		/// </summary>
		/// <param name="staffNo"></param>
		/// <returns></returns>
		bool CheckUser(string staffNo);

	}
	/// <summary>
	/// 后台用户登录数据
	/// </summary>
	public class AdminLoginUserData {
		/// <summary>
		/// 用户ID
		/// </summary>
		[ParamDescription("用户ID")]
		public string StaffNo { get; set; }

		/// <summary>
		/// 用户昵称
		/// </summary>
		[ParamDescription("用户昵称")]
		public string NickName { get; set; }

		/// <summary>
		/// 头像
		/// </summary>
		[ParamDescription("头像")]
		public string Avatar { get; set; }

		/// <summary>
		/// 用户名（登陆用）
		/// </summary>
		[ParamDescription("用户名（登陆用）")]
		public string LoginID { get; set; }

		/// <summary>
		/// User AccessToken
		/// </summary>
		[ParamDescription("User AccessToken")]
		public string AccessToken { get; set; }

		/// <summary>
		/// RefreshToken 刷新用户token用的
		/// </summary>
		[ParamDescription("RefreshToken 刷新用户token用的")]
		public string Refresh { get; set; }

		/// <summary>
		/// 会员过期时间
		/// </summary>
		[ParamDescription("会员过期时间")]
		public DateTime ExpiredTime { get; set; }
	}
}